<template>
  <div class="report">
    <!-- 面包屑导航栏 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item>
        <a href="/hello">首页</a>
      </el-breadcrumb-item>
      <el-breadcrumb-item>数据统计</el-breadcrumb-item>
      <el-breadcrumb-item>数据报表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card>
      <div class="main"></div>
    </el-card>
  </div>
</template>

<script>
// 导入echarts
import * as echarts from 'echarts';
import _ from 'lodash'
import { GetReport } from '@/api/api.js'
export default {
  name: 'BackShopReport',

  data () {
    return {
      // 需要合并的数据
      options: {
        title: {
          text: '用户来源'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            boundaryGap: false,
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ]
      }
    };
  },

  created () {

  },
  async mounted () {
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.querySelector('.main'));
    // 获取数据报表
    const { data: res } = await GetReport()
    if (res.meta.status !== 200) return this.$message.error('请求图标信息失败')
    // const relust1 = { ...this.options, ...res.data }
    const relust = _.merge(res.data, this.options)
    myChart.setOption(relust);

  },
  methods: {
    // 得到echarts

  },
};
</script>

<style lang="less" scoped>
.main {
  width: 700px;
  height: 500px;
}
</style>